package Tech.yunjing.onlineStorage.service;

import Tech.yunjing.onlineStorage.mapper.ResourcesMapper;
import Tech.yunjing.onlineStorage.module.Resources;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.UUID;

/**
 * Created by yo on 2016/6/23.
 * 需要同时操作db,file
 */
@Service
public class ResourcesService {

    @Autowired
    private ResourcesMapper resourcesMapper;

    public List<Resources> findList(){
        return resourcesMapper.findList();
    }

    /**
     * 保存
     * @param resources
     */
    public void save(Resources resources){
        String id = UUID.randomUUID().toString();
        resources.setId(id);
        resourcesMapper.save(resources);
    }


    /**
     * 保存
     * @param resources
     */
    public void update(Resources resources){
        resourcesMapper.update(resources);
    }
    /**
     * 根据id删除
     * @param
     */
    public void delete(String id){
        resourcesMapper.delete(id);
    }

    /**
     * 批量删除
     * @param
     */
    public void deleteBatch(List<String> ids){
        resourcesMapper.deleteBatch(ids);
    }
}
